<template>
  <div class="header">
    <div class="left">
      <el-button
        @click="handleMenu"
        icon="el-icon-menu"
        size="mini"
        style="margin-right: 20px"
      ></el-button>
      <!-- breadcrumb部分开始 -->
      <el-breadcrumb separator="/">
        <el-breadcrumb-item
          v-for="ele in currentBreadcrumbList"
          :key="ele.user"
          :to="{ path: `${ele.path}` }"
          >{{ ele.label }}</el-breadcrumb-item
        >
      </el-breadcrumb>
      <!-- breadcrumb部分结束 -->
    </div>
    <div class="right">
      <el-dropdown>
        <span class="el-dropdown-link">
          <img src="../assets/images/me.jpg" />
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      current: ''
    };
  },
  methods: {
    handleMenu() {
      //调用tab->modifiCollapse函数
      this.$store.commit("modifiCollapse");
    },
  },
  watch:{
    $route(i){
      this.current = i
    }
  },
  computed: {
    // currentBreadcrumbList当前面包屑的数据
    ...mapState({
      currentBreadcrumbList: (state) => state.tab.breadcrumbList,
    }),
  },
};
</script>

<style lang="less" scoped>
.header {
  display: flex;
  padding: 0 20px;
  justify-content: space-between;
  align-items: center;
  height: 60px;
  background-color: #333;

  .left {
    display: flex;
    align-items: center;
    /deep/.el-breadcrumb__item {
      .el-breadcrumb__inner {
        font-weight: normal;
        &.is-link {
          color: #666;
        }
      }
      &:last-child {
        .el-breadcrumb__inner {
          color: #fff;
        }
      }
    }
    .text {
      color: #fff;
      font-size: 14px;
      margin-left: 10px;
    }
  }

  .right {
    img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
  }
}
</style>